//最⻓连续递增序列（easy）: https://leetcode.cn/problems/longest-continuous-increasing-subsequence/description/
class Solution
{
public:
	int findLengthOfLCIS(vector<int>& nums)
	{
		int ret = 0, n = nums.size();
		for (int i = 0; i < n; )
		{
			int j = i + 1;
			// 找到递增区间的末端
			while (j < n && nums[j] > nums[j - 1])
			{
				j++;
			}
			ret = max(ret, j - i);
			i = j; // 直接在循环中更新下⼀个位置的起点
		}
		return ret;
	}
};

//买卖股票的最佳时机（easy）: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/description/
class Solution
{
public:
	int maxProfit(vector<int>& prices)
	{
		int ret = 0; // 记录最终结果
		for (int i = 0, prevMin = INT_MAX; i < prices.size(); i++)
		{
			ret = max(ret, prices[i] - prevMin); // 先更新结果
			prevMin = min(prevMin, prices[i]); // 再更新最⼩值
		}
		return ret;
	}
};